﻿using System;
using System.Diagnostics.CodeAnalysis;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime dt = DateTime.Now;
            ///日期格式
            Console.WriteLine(dt.ToString("yyyy-mm-dd hh:mm:ss:ms"));
            Console.WriteLine("当前时间："+dt);
            Console.WriteLine("日期："+dt.Date);
            Console.WriteLine("一个月的第几天："+dt.Day);
            Console.WriteLine("一周的星期几："+dt.DayOfWeek);
            Console.WriteLine("一年的第几天：" + dt.DayOfYear);
            Console.WriteLine("34天后的日期："+dt.AddDays(34));
            Console.WriteLine("5分钟后的时间:"+dt.AddMinutes(5));
            Console.WriteLine("3秒过后的时间"+dt.AddSeconds(3));
            Console.WriteLine("3小时过后的时间："+dt.AddHours(3));
            Console.WriteLine("再过一个多月放暑假啦！！！"+dt.AddMonths(1));
            Console.WriteLine("还有两年就毕业了"+dt.AddYears(2));


            DateTime birthday = new DateTime(2020, 12, 6);
            TimeSpan ts= birthday - dt;
            Console.WriteLine("2020年里我生日还差"+ts+"天");

            var first = "2020-5-01";
            var second=Convert.ToDateTime(first);///转换成日期字符串
            var lastday = second.AddDays(-1);///每个月的最后一天
            Console.WriteLine(lastday);
            



        }
    }
}
